import React, { Component } from 'react'
import { connect } from 'react-redux'
import action from './action'
class Home extends Component {
  componentDidMount () {
    this.props.getBannerList()
    this.props.getProList({ limitNum: 5 })
  }
  render() {
    const { proList } = this.props
    return (
      <div>
        {
          proList && proList.map(item => (
            <div key = { item.proid }>{ item.proname }</div>
          ))
        }
      </div>
    )
  }
}

export default connect(
  ({ home: { bannerList, proList } }) => ({ bannerList, proList }),
  (dispatch) => ({
    getBannerList () {
      dispatch(action.getBannerListAction)
    },
    getProList (params) {
      dispatch(action.getProListAction(params))
    }
  })
)(Home)
